using System;
using System.Collections;
using UnityEngine;
using UnityEngine.UI;

public class BloodScreen : MonoBehaviour
{
	public Image img;

	private void OnEnable()
	{
		StartCoroutine(Show());
		if (!Audio.instance.sfxLoop[0].isPlaying)
		{
			Audio.instance.sfxLoop[0].Play();
		}
	}

	private IEnumerator Show()
	{
		for (float f = 0f; f < 1f; f += Time.fixedDeltaTime * 5f)
		{
			img.color = new Color(0.1f, 0.1f, 0.1f, f);
			yield return new WaitForFixedUpdate();
		}
		while (true)
		{
			for (float f2 = 0.1f; f2 < 0.3f; f2 += Time.fixedDeltaTime * 0.1f)
			{
				img.color = new Color(f2, f2, f2);
				yield return new WaitForFixedUpdate();
			}
			for (float f3 = 0.3f; f3 > 0.1f; f3 -= Time.fixedDeltaTime * 0.1f)
			{
				img.color = new Color(f3, f3, f3);
				yield return new WaitForFixedUpdate();
			}
		}
	}

	private void OnDisable()
	{
		try
		{
			if (Audio.instance.sfxLoop[0].isPlaying)
			{
				Audio.instance.sfxLoop[0].Stop();
			}
		}
		catch (Exception)
		{
		}
	}
}
